<h1 align = 'center'>ADD RESERVATION</h1>
<form action = "<?=$base_url ?>pfmis/reservation/addreservation" method = 'POST'>
    <table align = 'center'>
        <tr>
            <td align = 'right'>Item to be reserved:</td>
            <td><select name = 'item'>
                <?php
                    $this->load->database();
                    $itemListQ = 'SELECT DISTINCT FacilityName FROM pf_facilities WHERE RoomAssigned = \'Server Room\' AND (FacilityType = \'Projector\' OR FacilityType = \'TV\') AND Status != -1';
                    $itemListR = $this->db->query($itemListQ);
                    if($itemListR->num_rows() > 0)
                    {
                        foreach($itemListR->result() as $itemList)
                        {
                            $itemCountQ = 'SELECT COUNT(FacilityID) as itemCount FROM pf_facilities WHERE FacilityName = \''.$itemList->FacilityName.'\' AND Status != -1';
                            $itemCountR = $this->db->query($itemCountQ);
                            $itemCount = $itemCountR->result();
                            echo '<option>'.$itemList->FacilityName.' - ['.$itemCount[0]->itemCount.']</option>';
                        }
                    }
                    else
                    {
                        echo '<option>FACILITY LIST EMPTY</option>';
                    }
                ?>
            </select></td>
        </tr>
        <tr>
            <td align = 'right'>Reserve Date:</td>
            <td>
                <select name = 'month'>
                    <option <?php if(date('m') == 01) { echo 'selected';}?> value = '01'>January</option>
                    <option <?php if(date('m') == 02) { echo 'selected';}?> value = '02'>February</option>
                    <option <?php if(date('m') == 03) { echo 'selected';}?> value = '03'>March</option>
                    <option <?php if(date('m') == 04) { echo 'selected';}?> value = '04'>April</option>
                    <option <?php if(date('m') == 05) { echo 'selected';}?> value = '05'>May</option>
                    <option <?php if(date('m') == 06) { echo 'selected';}?> value = '06'>June</option>
                    <option <?php if(date('m') == 07) { echo 'selected';}?> value = '07'>July</option>
                    <option <?php if(date('m') == 08) { echo 'selected';}?> value = '08'>August</option>
                    <option <?php if(date('m') == 09) { echo 'selected';}?> value = '09'>September</option>
                    <option <?php if(date('m') == 10) { echo 'selected';}?> value = '10'>October</option>
                    <option <?php if(date('m') == 11) { echo 'selected';}?> value = '11'>November</option>
                    <option <?php if(date('m') == 12) { echo 'selected';}?> value = '12'>December</option>
                </select>
                <select name = 'date'>
                    <?php
                        for($i = 1; $i <= 31; $i++)
                        {
                            echo '<option ';
                            if(date('d') == $i)
                                echo 'selected';
                            echo '>'.$i.'</option>';
                        }
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td align = 'right'>Time:</td>
            <td>
                <select name = 'time'>
                    <option>1:00</option>
                    <option>1:30</option>
                    <option>2:00</option>
                    <option>2:30</option>
                    <option>3:00</option>
                    <option>3:30</option>
                    <option>4:00</option>
                    <option>4:30</option>
                    <option>5:00</option>
                    <option>5:30</option>
                    <option>6:00</option>
                    <option>6:30</option>
                    <option>7:00</option>
                    <option>7:30</option>
                    <option>8:00</option>
                    <option>8:30</option>
                    <option>9:00</option>
                    <option>9:30</option>
                    <option>10:00</option>
                    <option>10:30</option>
                    <option>11:00</option>
                    <option>11:30</option>
                    <option>12:00</option>
                    <option>12:30</option>
                </select>
                <select name = 'ampm'>
                    <option>AM</option>
                    <option>PM</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align = 'right'>How Many Hour:</td>
            <td>
                <select name = 'hours'>
                    <option value = '1'>1 hour</option>
                    <option value = '1.5'>1 hour 30 mins</option>
                    <option value = '2'>2 hours</option>
                    <option value = '3'>3 hours</option>
                    <option value = '5'>5 hours</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align = 'right'>Professor:</td>
            <td>
                <select name = 'prof'>
                    <?php
                        $profListQ = 'SELECT MemberID,FirstName, LastName, Gender FROM faculty_member';
                        $profListR = $this->db->query($profListQ);
                        foreach($profListR->result() as $profList)
                        {
                            $address = 'Sir';
                            if($profList->Gender = 'Female')
                                $address = 'Ma\'am';
                            echo '<option value = '.$profList->MemberID.'>'.$address.' '.$profList->FirstName.' '.$profList->LastName.'</option>';
                        }
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td align = 'right'>Your Name:</td>
            <td><input type = 'text' name = 'reservedby'></td>
        </tr>
        <tr>
            <td colspan = 2 align = 'center'><input type = 'submit' value = 'Reserve'></td>
        </tr>
    </table>
</form>